package com.ly.lw.styledo.adapter;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;

import com.lidroid.xutils.BitmapUtils;
import com.ly.lw.styledo.R;
import com.ly.lw.styledo.beancategorysecondinfo.SnapList;

import java.util.List;

/**
 * Created by T400 on 15-7-10.
 */
public class CategoryInfoSecondAdapter extends AppBaseAdapter<SnapList> {

    private BitmapUtils bitmapUtils;

    public CategoryInfoSecondAdapter(List<SnapList> list, Context context, BitmapUtils bitmapUtils) {
        super(list, context);
        this.bitmapUtils = bitmapUtils;
    }

    @Override
    public View getItemView(int position, View convertView, ViewGroup parent) {
        ViewHolder vHolder = null;
        SnapList bean = list.get(position);
        if (convertView == null) {
            convertView = inflater.inflate(R.layout.category_info_second_data, parent, false);
            vHolder = new ViewHolder(convertView);
            convertView.setTag(vHolder);
        } else {
            vHolder = (ViewHolder) convertView.getTag();
        }
        String imageUrl = bean.getImg_url();
        imageUrl = imageUrl.replace("${width}", "500");
        bitmapUtils.display(vHolder.image, imageUrl);
        return convertView;
    }

    public static class ViewHolder {
        private ImageView image;

        public ViewHolder(View itemView) {
            image = (ImageView) itemView.findViewById(R.id.category_second_pic_data);
        }
    }
}
